package de.chessgame.gamelogic.piece;

import java.util.ArrayList;

import de.chessgame.gamelogic.Coordinate;

public class Queen extends Piece {

	public Queen(Fraction fraction) {
		super(Type.QUEEN, fraction);
	}

	@Override
	public void calculatePossibleMoves(Piece[][] content, int xOld, int yOld,
			boolean inCheck) {
		possibleMoves.clear();
		super.calculatePossibleMoves(content, xOld, yOld, inCheck);
		possibleMoves.addAll(givePossibleMovesForQueen(content, xOld, yOld));
	}

	@Override
	public boolean canMove(Piece[][] content, int xOld, int yOld,
			boolean inCheck) {
		return givePossibleMovesForQueen(content, xOld, yOld).size() != 0;
	}

	private ArrayList<Coordinate> givePossibleMovesForQueen(Piece[][] content,
			int xOld, int yOld) {
		ArrayList<Coordinate> list = new ArrayList<Coordinate>();
		list.addAll(givePossibleMovesDiagonally(content, xOld, yOld));
		list.addAll(givePossibleMovesAlongRankAndFile(content, xOld, yOld));
		list = removeIrregularyMoves(content, list, xOld, yOld);
		return list;
	}

}
